package hongcaosp.app.android.user.settings.safety;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import hongcaosp.app.android.R;
import hongcaosp.app.android.login.UserToken;
import hongcaosp.app.android.user.settings.safety.bind.BindPhoneActivity;
import hongcaosp.app.android.user.settings.safety.update.UpdatePasswordActivity;
import xlj.lib.android.base.component.BaseActivity;
import xlj.lib.android.base.utils.StatusBarUtil;

public class SafetyAndAccountActivity extends BaseActivity {

    private TextView tv_mobile;

    @Override
    protected void initData(Intent intent) {

    }

    @Override
    protected void initView() {
        StatusBarUtil.setStatusBarDarkTheme(this,false);
        tv_mobile = findViewById(R.id.tv_mobile);
        findViewById(R.id.back_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        findViewById(R.id.layout_update).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SafetyAndAccountActivity.this,UpdatePasswordActivity.class);
                startActivity(intent);
            }
        });
        findViewById(R.id.layout_bind).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SafetyAndAccountActivity.this,BindPhoneActivity.class);
                startActivity(intent);
            }
        });
    }

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_safety_and_account;
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (UserToken.getDefault().getUser() != null) {
            String mobile =  UserToken.getDefault().getUser().getMobile();
            if (TextUtils.isEmpty(mobile) || mobile.length() < 11) {
                return;
            }
            mobile = mobile.substring(0,3) + "****"  + mobile.substring(7);
            tv_mobile.setText("" + mobile);
        }
    }
}
